import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import App from './App.vue'
import router from './router' // 导入路由实例

// 导入全局公共组件
import SearchInput from '@/components/common/SearchInput.vue'
import PageContainer from '@/components/common/PageContainer.vue'
import TablePagination from '@/components/common/TablePagination.vue'

// Pinia 配置（修复重复 use 问题）
import { pinia } from './store/index'

const app = createApp(App)

// 注册 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 注册全局公共组件
app.component('SearchInput', SearchInput)
app.component('PageContainer', PageContainer)
app.component('TablePagination', TablePagination)

// 安装插件（顺序无关）
app.use(pinia)
app.use(router)
app.use(ElementPlus)

// 挂载 App
app.mount('#app')